
package com.yy.net.phpclass{
	import com.adobe.protocols.dict.Response;
	import com.yy.net.event.EventCenter;
	import flash.events.NetStatusEvent;
	import flash.net.NetConnection;
	import flash.net.Responder;
	import flash.net.URLRequest;
	import flash.events.NetStatusEvent;
	import com.maqie.GlobalMain;
	import com.maqie.GlobalConfig;
	
	
	import com.yy.net.event.PHPEvent;
	import com.maqie.debug.Debug;

	public class Server
	{
		protected var objConnect:NetConnection;
		protected var mid:int;
		
		public var objParam:GlobalConfig = GlobalMain.GetConfig();//加载网页传过来的参数
		
		public function Server(){}
		
		public function Serverinit(gateway:String,mid:int=0):void
		{
			this.objConnect = new NetConnection;
			this.mid = mid;
			var _gateway:String = gateway = null?"http://127.0.0.1/amfphp/gateway.php":gateway;
			this.objConnect.connect(_gateway);//objParam.gateway
			
			this.objConnect.addEventListener(NetStatusEvent.NET_STATUS, onStatus);
		}
		
		/**
		 * 一次调回数据
		 */
		public function loadObjParam(strKey:String,strMnick:String):void
		{
			
			this.objConnect.call("server.load", new Responder(onLoadObjParam, this.serverFault), strKey, strMnick);
		}
		
		private function onLoadObjParam(pr:Object):void
		{
			EventCenter.PHPEvent.dispatchEvent(new PHPEvent(PHPEvent.LOAD_PARAM_GET, pr)) ;
		}
		
		protected function serverFault(error:Object):void
		{
		}
		
		private function onStatus(e:NetStatusEvent):void
		{
			Debug.debug("连接状态："+e);
		}
	}
}